import { Injectable } from '@angular/core';
import { cacheOptions, preloadApp, setupApp } from 'wujie';

@Injectable({
  providedIn: 'root',
})
export class WuJieService {
  options: any[] = [];

  initialWuJiePreload(array: setupType[]) {
    for (let ele of array) {
      this.options.push(ele);
      setupApp({
        ...ele,
      });

      if (ele.preload) {
        preloadApp({name: ele.name});
      }
    }
  }
}

type setupType = cacheOptions & {
  /** 是否预加载 */
  preload?: boolean;
};
